import React, { useEffect} from 'react';
import { useRoutes,useLocation, useNavigate } from 'react-router-dom'
import router from './router'
function App() {
  const element = useRoutes(router)
  const location = useLocation()
  const navigate = useNavigate()
  //路由拦截
  useEffect(() => { 
    if (location.pathname === '/home/user'&&!localStorage.token) {
        navigate('/login')
     }
  },[location,navigate])
  return (
    <div className="App">
      { element}
    </div>
  );
}

export default App;
